package yb.ecp.fast.user.service.VO;

import org.apache.commons.lang3.StringUtils;
import yb.ecp.fast.user.infra.ErrorCode;

/**
 * @Des 密码重置实体
 * @Date 2021/4/25 10:07
 * @Author wangzhaoyu
 * @Param
 * @Return
 */
public class PasswordResetVO {

    private String loginName;

    private String oldPassword;

    private String newPassword;

    private String confirmPassWord;

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getOldPassword() {
        return oldPassword;
    }

    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }

    public String getNewPassword() {
        return newPassword;
    }

    public void setNewPassword(String newPassword) {
        this.newPassword = newPassword;
    }

    public String getConfirmPassWord() {
        return confirmPassWord;
    }

    public void setConfirmPassWord(String confirmPassWord) {
        this.confirmPassWord = confirmPassWord;
    }

    public ErrorCode checkParamSubmit(){
        String confirmPassWord = this.getConfirmPassWord();
        String loginName = this.getLoginName();
        String oldPassword = this.getOldPassword();
        String newPassword = this.getNewPassword();
        if(StringUtils.isEmpty(loginName)){
            return ErrorCode.UserLoginNameCannotBeNull;
        }
        if(StringUtils.isEmpty(oldPassword)){
            return ErrorCode.OldPwdCanNotBeNull;
        }
        if(StringUtils.isEmpty(newPassword)){
            return ErrorCode.NewPwdCanNotBeNull;
        }
        if(StringUtils.isEmpty(confirmPassWord)){
            return ErrorCode.ConfirmPwdCanNotBeNull;
        }
        if(newPassword.equals(oldPassword)){
            return ErrorCode.NewPwdAndOldPwdCannotEquals;
        }
        if(!newPassword.equals(confirmPassWord)){
            return ErrorCode.NewPwdAndConfirmPwdNotEquals;
        }
        return ErrorCode.Success;
    }
}
